package top.cwk.dubbo.core.service.customer;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.cwk.dubbo.api.customer.ICustomerService;
import top.cwk.dubbo.core.mapper.CustomerMapper;
import top.cwk.dubbo.entity.customer.Customer;

@Service("customerService")
public class CustomerServiceImpl implements ICustomerService{
	
	@Autowired
	private CustomerMapper customerMapper;
	
	@Override
	public List<Customer> getAllCustomer() {
		return customerMapper.selectAll();
	}

	@Override
	public Customer getCustomerById(Integer customerid) {
		return customerMapper.selectById(customerid);
	}

	@Override
	public void saveCustomer(Customer customer) {
		if(customer.getCustomerid()!=null){
			customerMapper.updateCustomer(customer);
		}else{
			customerMapper.insertCustomer(customer);
		}
	}

}
